package com.example.demo.main.rabbitmq.exchange.direct;

import com.example.demo.main.rabbitmq.utils.RabbitmqConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

/**
 * @author xieluoyin
 */
public class Producer4DirectExchange {


    public static void main(String[] args) throws Exception {


        //2 创建Connection
        Connection connection = RabbitmqConnectionUtil.getConnection();
        //3 创建Channel
        Channel channel = connection.createChannel();
        //4 声明
        String exchangeName = "test_direct_exchange";
        String routingKey = "test.direct";
        //String routingKey = "test.direct111";
        //5 发送
        String msg = "Hello World RabbitMQ 4  Direct Exchange Message  ... ";
        channel.basicPublish(exchangeName, routingKey, null, msg.getBytes());
        channel.close();
        connection.close();

    }

}
